package com.symone.webcms.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.symone.webcms.mapper.LoginLogMapper;
import com.symone.webcms.model.LoginLog;
import com.symone.webcms.service.LoginLogService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *　　
 *   @description : LoginLog 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2018-11-18
 */
@Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService {

    @Override
    public Page<LoginLog> findPage(Page<LoginLog> page, Wrapper<LoginLog> entity) {
        List<LoginLog> result = baseMapper.selectPage(page,entity);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<String> getDistinctYmByCreateTime(String loginName) {
        return baseMapper.getDistinctYmByCreateTime(loginName);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean deleteFlagById(long id) {
        return baseMapper.deleteFlagById(id);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<LoginLog>().eq("deleted" ,1));
    }

    @Override
    public int deleteAll() {
        return baseMapper.delete(new EntityWrapper<LoginLog>().where("1=1"));
    }

}
